package com.cat.dataStructure02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/
 * @create 2025/10/23 16:24
 * @since JDK17
 */

public class Solution52 {
    public int minNumberOperations(int[] target) {
        int ans = 0, x = 0, n = target.length;
        for (int i = 0; i < n; i++) {
            if (x < target[i]) {
                ans += target[i] - x;
            }
            x = target[i];
        }

        return ans;
    }
}
